#ifndef STYLEHELPER_H
#define STYLEHELPER_H

#include "corelib_global.h"

#include <QColor>
#include <QPalette>
#include <QStyle>

class CORELIBSHARED_EXPORT StyleHelper
{
public:
    static const unsigned int DEFAULT_BASE_COLOR = 0xffffff;

    StyleHelper();

    static int navigationWidgetHeight() { return 24; }
    static qreal sidebarFontSize();
    static QPalette sidebarFontPalette(const QPalette &original);

    static QColor requestedBaseColor() { return m_requestedBaseColor; }
    static QColor baseColor(bool lightColored = false);
    static QColor panelTextColor(bool lightColored = false);
    static QColor highlightColor(bool lightColored = false);
    static QColor shadowColor(bool lightColored = false);
    static QColor borderColor(bool lightColored = false);
    static QColor buttonTextColor() { return QColor(0x4c4c4c); }
    static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);

    static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); }
    static QColor sidebarShadow() { return QColor(0, 0, 0, 40); }
    static void setBaseColor(const QColor &color);

    static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);

    static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
    static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
    static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
    static bool usePixmapCache() { return true; }

    static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode,
                                   int radius = 3, const QColor &color = QColor(0, 0, 0, 130),
                                   const QPoint &offset = QPoint(1, -2));
    static void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
                         int left = 0, int top = 0, int right = 0, int bottom = 0);

    static void tintImage(QImage &img, const QColor &tintColor);
    static void backgroundGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);

protected:
    static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored);
    static void horizontalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored);
    static void menuGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect);
private:
    static QColor m_baseColor;
    static QColor m_requestedBaseColor;
};

#endif // STYLEHELPER_H
